package com.shhic.hhplt.server.bkgrdui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.shhic.hhplt.server.model.User;

//登录拦截器
@Component
public class LoginInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
        User loginUser = (User) request.getSession().getAttribute("loginUser");  
        if(loginUser == null){
        	response.getWriter().write("nologin");
        	return false;
        }
        return true;
	}
}
